//
//  ZcViewController.m
//  UI_豆瓣影院
//
//  Created by dllo on 16/1/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ZcViewController.h"
#import "LTView.h"
#import "FourViewController.h"
#import "AAALHXDateHandle.h"
#import "myModel.h"
@interface ZcViewController ()<UITextFieldDelegate>
@end

@implementation ZcViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)dealloc {
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"注册";
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(itemAction)];
    self.navigationItem.rightBarButtonItem = item;
   
    
    LTView *view = [[LTView alloc] initWithFrame:CGRectMake(20, 40, 300, 40)];
    view.myLable.text = @"用户名:";
    view.myTextField.placeholder = @"请输入用户名";
    view.myTextField.delegate = self;
    view.myTextField.tag = 1000;
    [self.view addSubview:view];
    [view release];
   
    LTView *view1 = [[LTView alloc] initWithFrame:CGRectMake(20, 100, 300, 40)];
    view1.myLable.text = @"密码:";
    view1.myTextField.placeholder = @"请输入密码";
    view1.myTextField.delegate = self;
    view1.myTextField.tag = 1001;
    [self.view addSubview:view1];
    [view1 release];
   
    LTView *view2 = [[LTView alloc] initWithFrame:CGRectMake(20, 160, 300, 40)];
    view2.myLable.text = @"确认密码:";
    view2.myTextField.placeholder = @"再次输入密码";
    view2.myTextField.delegate = self;
    view2.myTextField.tag = 1002;
    [self.view addSubview:view2];
    [view2 release];
   
    LTView *view3 = [[LTView alloc] initWithFrame:CGRectMake(20, 220, 300, 40)];
    view3.myLable.text = @"邮箱:";
    view3.myTextField.placeholder = @"请输入邮箱";
    view3.myTextField.delegate = self;
    view3.myTextField.tag = 1003;
    [self.view addSubview:view3];
    [view3 release];
   
    LTView *view4 = [[LTView alloc] initWithFrame:CGRectMake(20, 280, 300, 40)];
    view4.myLable.text = @"联系方式:";
    view4.myTextField.placeholder = @"请输入联系方式";
    view4.myTextField.delegate = self;
    view4.myTextField.tag = 1004;
    [self.view addSubview:view4];
    [view4 release];
    
    
    
    
    
}

- (void)itemAction {
    UITextField *fie = [self.view viewWithTag:1000];
    UITextField *fie1 = [self.view viewWithTag:1001];
    myModel *model = [myModel model];
    model.name = fie.text;
    model.pwd = fie1.text;
    model.type = 1;
    [[AAALHXDateHandle sharedDateBaseHandle] insertModel2:model];
//    model.name = @"liu";
//    [[AAALHXDateHandle sharedDateBaseHandle] deleteModel2:model.name];
     // 调回第四界面
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    
    
    
}

// 键盘文本按位移动
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    
    UITextField *fie = [self.view viewWithTag:textField.tag + 1];
    [fie becomeFirstResponder];
    return YES;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
